package com.yingside.collection;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class TestMap2 {
    public static void main(String[] args) {
        List<Student> stus1 = new ArrayList<>();
        List<Student> stus2 = new ArrayList<>();
        Student s1 = new Student(1,"张三1","1231231");
        Student s2 = new Student(2,"张三2","1231232");
        Student s3 = new Student(3,"张三3","1231233");
        stus1.add(s1);
        stus1.add(s2);

        stus2.add(s3);

        Teacher t1 = new Teacher(1,"李老师");
        Teacher t2 = new Teacher(2,"李老师");



        Map<Teacher,List<Student>> map = new HashMap<>();

        map.put(t1,stus1);
        map.put(t2,stus2);

        System.out.println("=======" + map.size());

        //注意上面的写法也是没有任何问题的，但是需要注意一个问题
        //现在的键是引用数据类型，但是键是以set形式保存的，会自动的去重复
        //如果类重写了equals和hashcode方法，就会根据你自己定义的方式去重复

        List<Student> studentList = map.get(t2);
        System.out.println("studentList = " + studentList);
    }
}
